<template>
  <div style="background: #fff">
    <div class="title">
      <div>{{ title }}</div>
    </div>
    <div style="padding: 1.875rem">
      <el-form :inline="true">
        <el-form-item label="">
          <el-input
            v-model="query.name"
            placeholder="标题"
          ></el-input>
        </el-form-item>
        
        <el-form-item>
          <el-button type="success" @click="getData(true)">查询</el-button>
          <el-button @click="reset">重置</el-button>
          <el-button type="primary" @click="showEdit(-1)">添加</el-button>
        </el-form-item>
      </el-form>
    </div>
    
    <el-table :data="data" stripe style="width: 100%; margin-bottom: 1.875rem">
      <el-table-column prop="id" label="id"></el-table-column>
      <el-table-column prop="name" label="标题"></el-table-column>
     
      <el-table-column label="小程序链接">
        <template slot-scope="scope" >
          {{'/pages/articleDetail/index?id='+scope.row.id}}
        </template>
      </el-table-column>

     
      

      
      <el-table-column label="操作" width="200">
        <template slot-scope="scope">
          <el-button size="small" @click="showEdit(scope.row.id)"
            >编辑</el-button
          >
          <el-button
            type="error"
            size="small"
            @click="del(scope.row)"
            
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pages.currentPage"
      :page-size="pages.per_page"
      layout="total,prev, pager, next"
      :total="pages.total"
      style="text-align: center"
    >
    </el-pagination>

    
  </div>
</template>

<script>
import mixin from "../../js/mixin";

export default {
  name: "homePage",
  mixins: [mixin],
  data() {
    return {
      
      is_page: true,
      api_url:'article',
      item: {},
      query: {
        
      },
    };
  },
  components: {},
  mounted() {
  
  },
  created() {
    this.admin_type = localStorage.getItem('admin_type')
    this.title = this.$route.meta.title
    this.init()
    
  },
  methods: {
    reset() {
      this.query = {
        
      },
      this.getData(true)
    },
    init(){
      this.getData()
    },
   
    showEdit(e) {
      let { href } = this.$router.resolve({
        name: "articleDetail",
        params: { id:e },
        query: {
        }
      });
      window.open(href, "_blank");
    },
   
  },
};
</script>

